import * as fs from 'fs'
import nconf from 'nconf'

nconf.argv()
  .env()

const configFile = nconf.get('configFile')
if (configFile && fs.statSync(configFile).isFile()) {
  nconf.file(configFile)
}

const dataSource = {
  uri: nconf.get('dataSource:uri') || 'mongodb://root:root@localhost:27017/test?authSource=admin'
}

const server = {
  port: nconf.get('server:port') || 3000
}

export {
  dataSource,
  server
}

export default nconf

export function isDevMod () {
  return nconf.get('NODE_ENV_PASSME') === 'dev'
}
